package com.zzwc.vote.www.service.impl;

import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.zzwc.vote.utils.PageUtils;
import com.zzwc.vote.utils.Query;
import com.zzwc.vote.www.entity.VoteEnterprise;
import com.zzwc.vote.www.entity.VoteTerritory;
import com.zzwc.vote.www.mapper.VoteEnterpriseMapper;
import com.zzwc.vote.www.service.IVoteEnterpriseService;
import com.zzwc.vote.www.service.IVoteTerritoryService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author weirdor
 * @since 2018-06-06
 */
@Service
public class VoteEnterpriseServiceImpl extends ServiceImpl<VoteEnterpriseMapper, VoteEnterprise> implements IVoteEnterpriseService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String name = (String)params.get("name");

        String id = (String)params.get("id");

        EntityWrapper<VoteEnterprise> wrapper=new EntityWrapper<>();
        if (StringUtils.isNotBlank(name)){
            wrapper.like(StringUtils.isNotBlank(name),"name", name);
        }
        else if (StringUtils.isNotBlank(id)){
            wrapper.like(StringUtils.isNotBlank(id),"id", id);
        }

        Page<VoteEnterprise> page = this.selectPage(
                new Query<VoteEnterprise>(params).getPage(),
               wrapper
        );

        return new PageUtils(page);
    }
}
